import ajaxHelper from '../../common/ajaxHelper'
import utilHelper from '../../common/utilHelper'

const BANNER_URL = 'SimpleContent/GetSimpleContentDetail'

let viewModel = {
    model: {
        id: 0,
        Type: 0,
        Description: '',
        CreateDate: '',
        SimpleContent: ''
    },
    convertBanner(item){
        // Description CreateDate SimpleContent Type id
        var banner = {
            id: item.id,
            Type: item.Type,
            Description: item.Description,
            CreateDate: utilHelper.formatDateT(item.CreateDate),
            SimpleContent: item.SimpleContent
        };
        var result = {banner};

        return result;
    }
}

export default {
    banner: viewModel.model,
    getBannerById(id, callback){
        var data = {ID : id};
        ajaxHelper.Post(BANNER_URL, data, function(result){
            if(result.Code == 1 && result.Data){
                var item = viewModel.convertBanner(result.Data);
                callback && callback(item);
            }
        })
    }
}    